<template>
  <div style="text-align: center;width: 70%">
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="手机号">
        <el-input placeholder="请输入手机号" v-model="form.tel"></el-input>
      </el-form-item>
      <el-form-item label="验证码">
        <el-input placeholder="请输入内容" v-model="form.code">
          <el-button slot="append" @click="getMessageCode">点击获取验证码</el-button>
        </el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="toNext" type="primary">下一步</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  export default {
    name: "test-tel",
    data() {
      return {
        form: {
          tel: "",
          code: ""
        }
      }
    },
    methods: {
      toNext() {
        this.$store.state.tel = this.form.tel;
        this.$axios.get(this.$gloableData.serverPath + "auth/toNext", {
          params: {
            code: this.form.code
          }
        }).then((response) => {
          if (response.data) {

            this.$emit("TT")
          } else {
            this.$message('验证码输入错误');
          }
        })

      },
      getMessageCode() {
        this.$axios.get(this.$gloableData.serverPath + "auth/smsyzm", {
          params: {
            phone: this.form.tel
          }
        }).then((response) => {
          if (response.data) {
            this.rex=response.data;
            this.$message({
              message: '获取验证码成功',
              type: 'success'
            });
          } else {
            this.$message('获取失败');
          }
        })
      }
    }
  }
</script>

<style scoped>

</style>
